/**
 * 
 */
package model;

import java.util.ArrayList;
import java.util.List;

import common.DataManager;
import common.GridCoordinate;

/**
 * @author Bill
 *
 */
public abstract class HomingMissile extends ManualWeapon {

	private int zombosaurCount = 2;	//default value
	
	//SmallHomingMissile without position
	public HomingMissile(String name, String imageName, String ammoImageName, int cost, int damage, int speed, int rangeInt, int zombosaurCount){
		super(name, imageName, ammoImageName, cost, damage, speed, rangeInt);
		this.zombosaurCount = zombosaurCount;
	}

	@Override
	public void createRange() {
		List<GridCoordinate> r = new ArrayList<GridCoordinate>();
		if(getRangeInt() == 0){
			r.add(getPosition());
		}
		else{
			for( int i = -1*this.getRangeInt(); i <= this.getRangeInt(); ++i ){
				for( int j = -1*this.getRangeInt(); j <= this.getRangeInt(); ++j ){
					r.add( new GridCoordinate( getPosition().getX() + i, getPosition().getY() + j));
				}
			}
		}
		setRange(r);
	}

	@Override
	public HomingMissileAmmo useAmmo(){
		return (HomingMissileAmmo) this.getAmmo().pop();
	}
	
	@Override 
	public void addAmmo(){
		this.getAmmo().push(new HomingMissileAmmo(this.zombosaurCount, this));
	}
}
